package hadoop.mr05;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class PhoneReducer extends Reducer<Phone, Text,Text, NullWritable> {
    Text t1 = new Text();
    @Override
    protected void reduce(Phone key, Iterable<Text> values, Reducer<Phone, Text, Text, NullWritable>.Context context) throws IOException, InterruptedException {
        String head = key.toString();
        String vt = null;
        for(Text t1:values){
            vt = t1.toString();
        }
        String concat = head+":"+vt;
        t1.set(concat);
        // todo 这个时候不便利，输出就是排序后的第一个值
        context.write(t1,NullWritable.get());
    }
}
